<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@ taglib uri="/mytag" prefix="yjd"%>
<div class="wrap">
	<div class="nav">
		<div class="return">
			<a href='<yjd:url url="/project/all"/>'>返回上一页</a>
		</div>
	</div>
	<!-- start -->
	<form method="post" enctype="multipart/form-data" class="J_ajaxForm" autocomplete="off" action='<yjd:url url="/project/add/submit"/>'>
		<div class="table_full">
			<table width="100%">
				<tr>
					<th width="200">项目名称:</th>
					<td>
						<input name="project_name" type="text" class="input length_5" value="${project.project_name}">
						<input name="project_id" type="hidden" class="input length_5" value="${project.project_id}">
					</td>
				</tr>
				<tr>
					<th>项目图片:</th>
					<td>
						<input name="project_pic" type="hidden" class="input length_5" value="${project.project_pic}">
						<input name="project_imgfile" type="file" class="input length_5" >
						<c:if test="${project_pic != null}">(<a target="_black" href="${project_pic}">已经上传，点击查看</a>)</c:if>
					</td>
				</tr>
				<tr>
					<th>项目分类:</th>
					<td>
						<select name="category_id" id="category_id" class="mr10" >
							<c:forEach items="${projectCgy }" var="item">
								<option ${item.key==project.category_id?"selected='selected'":"" } value="${item.key }">${item.value }</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<th width="200">项目价格:</th>
					<td>
						<input name="project_price" type="text" class="input length_5" value="${project.project_price}" placeholder="单位：元">
					</td>
				</tr>
				<tr>
					<th width="200">售卖价格:</th>
					<td>
						<input name="act_price" type="text" class="input length_5" value="${project.act_price}" placeholder="单位：元">
					</td>
				</tr>
				<tr>
					<th width="200">单个项目固定贷款额度:</th>
					<td>
						<input name="loan_price" type="text" class="input length_5" value="${project.loan_price}" placeholder="单位：元">
					</td>
				</tr>
				<c:if test="${project.rate_config!=null&&rateList!=null}">
					<tr>
						<input name="rate_config" type="hidden" class="input length_5" value='${project.rate_config}'>
						<th width="200">分期利率配置:</th>
						<td>
							<ul class="single_list cc">
								<c:forEach items="${rateList}" var="rateInfo" >
									<li>期数:${rateInfo.limit},利率:${rateInfo.rate}</li>
								</c:forEach>
							</ul>
						</td>
					</tr>
				</c:if>
				<tr>
					<th width="200">所属机构:</th>
					<td>
						<select name="org_id" id="org_id" class="mr10" onchange="queryDoctor()">
							<c:forEach items="${orgids }" var="item">
								<option ${item.key==project.org_id?"selected='selected'":"" } value="${item.key }">${item.value }</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<th>负责医生:</th>
					<td>
						<select name="doctor_id" id="doctor_id" class="mr10" >
							<option value="0">请选择</option>
							<c:forEach items="${doctorAndName }" var="item">
								<option ${item.key==project.doctor_id?"selected='selected'":"" } value="${item.key }">${item.value }</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<th width="100">热搜标签：(建议不要超过5个标签)</th>
					<td colspan="2">
						<table>
							<c:forEach items="${tagModelList }" var="item" varStatus="status">
							<c:if test="${status.count==0}" >
							<tr>
								</c:if>
								<c:if test="${status.count%8==1}" >
							</tr><tr>
							</c:if>
							<td><input type="checkbox" value="${item.tag_id }" name="tags" <c:if test="${item.strMap.isCheck==true}">checked</c:if>>${item.tag_name }</input></td>
							</c:forEach>
						</table>
					</td>
				</tr>
				<tr>
					<th>项目简介:</th>
					<td><textarea rows="5" cols="60" name="intro">${project.intro}</textarea></td>
				</tr>
				<tr>
					<th>项目详情:</th>
					<td>
						<input name="detail_id" type="hidden" class="input length_5" value="${project.detail_id}">
						<textarea name="detail" class="J_editor">${project.strMap.detail}</textarea>
					</td>
				</tr>
				<tr>
					<th>是否启用:</th>
					<td>
						<label><input name="is_used" type="radio" value="1" <c:if test="${project.is_used == 1}">checked</c:if>/>是</label>
						<label><input name="is_used" type="radio" value="0" <c:if test="${project.is_used == 0}">checked</c:if>/>否</label>
					</td>
				</tr>
				<tr>
					<th>是否推广:</th>
					<td>
						<label><input name="is_spread" type="radio" value="1" <c:if test="${project.is_spread == 1}">checked</c:if>/>是</label>
						<label><input name="is_spread" type="radio" value="0" <c:if test="${project.is_spread == 0}">checked</c:if> />否</label>
					</td>
				</tr>
			</table>
		</div>
		<input class="btn btn_submit J_ajax_submit_btn" type="submit" value="确认保存">
	</form>
</div>

<script>

    Upload_Config = {url : "${requestScope.FPWEB.rootPath }/resource/upload${requestScope.FPWEB.urlStuff}?type=2",uid : "${uid}",sign : "${sign}"};
    YJD.use('AppAdminCommon');

    function queryDoctor() {
        $.ajax({
            type : "post",
            url : "${requestScope.FPWEB.rootPath }/project/org/doctor${requestScope.FPWEB.urlStuff}",
            data : {"org_id":$("#org_id").val()},
            error : function(request) {
                alert("连接失败！");
            },
            success : function(result) {
                if (result.state == 1) {
                    $("#doctor_id").empty();
                    $("#doctor_id").append('<option value="0">请选择</option>')
                    doctorIds = result.data.doctorAndName;
                    for(var dId in doctorIds){
                        $("#doctor_id").append("<option value="+dId+">"+doctorIds[dId]+"</option>")
                    }
                }
            }
        });
    };
</script>
